package com.dwxt.cdms.controller;

import com.dwxt.cdms.entity.EquipmentCustom;
import com.dwxt.cdms.service.EquipmentCustomService;
import com.dwxt.cdms.view.EquipmentCustomView;
import com.dwxt.cdms.vo.SelectEquipmentCustomVo;
import com.dwxt.common.base.BaseResult;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 设备&客户 关联
 *
 * @author Kuang.JiaZhuo
 * @date 2020-09-05 16:26
 */
@RestController
@RequestMapping("/cdms/equipmentCustom")
public class EquipmentCustomController {

    @Resource
    EquipmentCustomService equipmentCustomService;

    /**
     * @方法名：bindEquipment
     * @描述： 绑定设备
     * @作者： kjz
     * @日期： Created in 2020/9/5 16:30
     */
    @RequestMapping("/bindEquipment")
    public BaseResult bindEquipmentCustom(EquipmentCustom equipmentCustom) throws IOException {
        int result = equipmentCustomService.bindEquipment(equipmentCustom);
        return BaseResult.ok(result);
    }

    /**
     * @方法名：unbindEquipmentCustom
     * @描述： 解除绑定
     * @作者： kjz
     * @日期： Created in 2020/9/11 19:13
     */
    @RequestMapping("/unbindEquipment")
    public BaseResult unbindEquipmentCustom(String equipmentId) throws IOException {
        int result = equipmentCustomService.unbindEquipment(equipmentId);
        return BaseResult.ok(result);
    }

    /**
     * @方法名：selectEquipmentCustomById
     * @描述： 根据id查询【设备&客户】详情
     * @作者： kjz
     * @日期： Created in 2020/9/5 16:44
     */
    @RequestMapping("/selectEquipmentCustomById")
    public BaseResult selectEquipmentCustomById(String id) {
        EquipmentCustomView equipmentCustomView = equipmentCustomService.selectEquipmentCustomById(id);
        return BaseResult.ok(equipmentCustomView);
    }

    /**
     * @方法名：selectEquipmentCustomList
     * @描述： 按条件查询【设备&客户】列表(带分页)
     * @作者： kjz
     * @日期： Created in 2020/9/5 17:37
     */
    @RequestMapping("/selectEquipmentCustomList")
    public BaseResult selectEquipmentCustomList(SelectEquipmentCustomVo selectVo) {
        PageInfo<EquipmentCustomView> pageInfo = equipmentCustomService.selectEquipmentCustomList(selectVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：deleteDataByIds
     * @描述： 批量删除【设备&客户】
     * @作者： kjz
     * @日期： Created in 2020/9/5 14:51
     */
    @RequestMapping("/deleteDataByIds")
    public BaseResult deleteDataByIds(String[] ids) throws IOException {
        int result = equipmentCustomService.deleteDataByIds(ids);
        return BaseResult.ok(result);
    }

    @RequestMapping("/selectEquipmenctType")
    public BaseResult selectEquipmentType(Integer customerId) {
        return equipmentCustomService.selectEquipmenctType(customerId);
    }

    /**
    * @Description: 获取客户设备列表
    * @Param [customerId]
    * @Return com.dwxt.common.base.BaseResult
    * @Author chendq
    * @Date 2022/3/21
    **/
    @RequestMapping("/selectEquipmentListByCustomerId")
    public BaseResult selectEquipmentListByCustomerId(@RequestParam(required = true) Integer customerId) {
        return equipmentCustomService.selectEquipmentListByCustomerId(customerId);
    }

    /**
    * @Description: 通过设备序列号查询客户信息
    * @Param [serialNumber]
    * @Return com.dwxt.common.base.BaseResult
    * @Author chendq
    * @Date 2022/3/21
    **/
    @RequestMapping("/selectCustomerBySerialNumber")
    public BaseResult selectCustomerBySerialNumber(@RequestParam(required = true) String serialNumber) {
        return equipmentCustomService.selectCustomerBySerialNumber(serialNumber);
    }


}
